<template>
	<view class="page">
		<uni-list class="list user-section">
			<uni-list-item :title="userInfo.username"  :note="userInfo.nickname"  :thumb="userInfo.headimg" @tap="listItemTap('/pages/ucenter/user-info-edit/user-info-edit')"/>
			<uni-list-item v-for="(item, index) of userSectionConfig" :key="index" :title="item.leftTitle" :rightText="item.rightTitle" @click="listItemTap(item.url)"/>
		</uni-list>
		
		<uni-list class="list account-section">
			<uni-list-item v-for="(item, index) of accountSectionConfig" :key="index" :title="item.leftTitle" :rightText="item.rightTitle"  @click="listItemTap(item.url)"/>
		</uni-list>
		
		<uni-list class="list functional-section">
			<uni-list-item v-for="(item, index) of functionalSectionConfig" :key="index" :title="item.leftTitle" :rightText="item.rightTitle" @click="listItemTap(item.url)" />
		</uni-list>
		
		<view class="logout-btn">
			<text class="logout-btn-text" @tap="logoutBtnTap">退出登录</text>
		</view>
		
		<view class="bottom-placeholder"></view>
	</view>
</template>

<script>
	import initConfig from '@/mixins/ucenter/setting/setting.js';
	import data from '@/data/ucenter/setting/setting.js';
	export default {
		mixins: [initConfig],
		data() {
			return {
				userInfo: {},
			}
		},
		async onLoad() {
			const userInfoData = data.userInfo();
			this.userInfo = await userInfoData;
		},
		methods: {
			listItemTap(url) {
				uni.navigateTo({
					url: url,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			logoutBtnTap() {
				uni.showModal({
					title: '确定退出登录',
					content: '',
					showCancel: true,
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if(res.confirm){
							this.$Helper.clearCache();
							setTimeout(res=>{
								this.$Helper.tpfJump({url:"/pages/ucenter/login/login"});
							},1000);
						}
					},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>

<style lang="scss">
	.list {
		margin-bottom: $uni-spacing-row-base;
		border-radius: $uni-border-radius-base;
	}
	
	.user-section {
		border-top-left-radius: 0;
		border-top-right-radius: 0;
	}
	
	.logout-btn {
		/* #ifndef APP-PLUS-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		align-items: center;
		
		border-radius: $uni-border-radius-base;
		background-color: $uni-bg-color;
		height: 100rpx;
		
		
	}
	.logout-btn-text {
		font-size: $uni-font-size-base;
	}
	
	.bottom-placeholder {
		height: $uni-spacing-row-base;
	}
</style>
